package org.smartboot.sosa.core.rmi;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 服务器监测定时器
 *
 * @author Seer
 * @version QuickMonitorTimer.java, v 0.1 2015年3月18日 下午11:25:21 Seer Exp.
 */
public class QuickMonitorTimer extends QuickTimerTask {

	/** 当前周期内处理消息数 */
	private AtomicInteger processMsgNum = new AtomicInteger(0);

	private volatile long totleProcessMsgNum = 0;

	@Override
	protected long getDelay() {
		return getPeriod();
	}

	@Override
	protected long getPeriod() {
		return TimeUnit.MINUTES.toMillis(1);
	}

	public void processFilter() {
		processMsgNum.incrementAndGet();
		totleProcessMsgNum++;
	}

	@Override
	public void run() {
		int curProcessMsgNum = processMsgNum.getAndSet(0);
		System.out.println(
			"\r\nNum of Process Msg:\t" + curProcessMsgNum + "\r\nTotal Num of Process Msg:\t" + totleProcessMsgNum);
	}

}
